#include "hf_dev_abstract.h"

int8_t hf_device_register(struct hf_device *dev, enum hf_device_type type)
{
    if (dev == NULL || dev->ops == NULL) return ERR_INVALID_PARAM;
        dev->type = type;
        
    return ERR_OK;
}
int8_t hf_device_open(struct hf_device *dev) 
{
    if (dev == NULL || dev->ops == NULL || dev->ops->open == NULL) return ERR_INVALID_PARAM;
    return dev->ops->open(dev);
}

int8_t hf_device_close(struct hf_device *dev) 
{
    if (dev == NULL || dev->ops == NULL || dev->ops->close == NULL) return ERR_INVALID_PARAM;
    return dev->ops->close(dev);
}

int8_t hf_device_read(struct hf_device *dev, uint8_t *p_data, uint16_t size)
{
    if (dev == NULL || dev->ops == NULL || dev->ops->read == NULL) return ERR_INVALID_PARAM;
    return dev->ops->read(dev, p_data, size);
}

int8_t hf_device_write(struct hf_device *dev, uint8_t *p_data, uint16_t size)
 {
    if (dev == NULL || dev->ops == NULL || dev->ops->write == NULL) return ERR_INVALID_PARAM;
    return dev->ops->write(dev, p_data, size);
}

int8_t hf_device_ioctl(struct hf_device *dev, uint32_t cmd, void *arg)
 {
    if (dev == NULL || dev->ops == NULL || dev->ops->ioctl == NULL) return ERR_INVALID_PARAM;
    return dev->ops->ioctl(dev, cmd, arg);
}

